function ShowHide(id) {
	if ( itm = document.getElementById(id) ) {
		if (itm.style.display == 'none'){
			itm.style.display = '';
		} else {
			itm.style.display = 'none';
		}
	}
}

function changevalue(id, value) {
	var obj = document.getElementById(id);
	obj.value = value;
}

function getid(id) {
	return document.getElementById(id);
}

function showmenu(id) {
	var thismenu=document.getElementById(id);
	thismenu.style.display="block";
}

function hidemenu(id) {
	var thismenu=document.getElementById(id);
	thismenu.style.display="none";
}

/**
 * 判断中英问混排时候的长度
 * @param string sStr: 混排的字符串
 */
function byteLength (sStr) {
	aMatch = sStr.match(/[^\x00-\x80]/g);
	return (sStr.length + (! aMatch ? 0 : aMatch.length));
}


function hidetoolbar() {
	window.parent.document.getElementById("toolbarframe").style.display="none";
}

function hidetoolbarOpera() {
	if (navigator.userAgent.toLowerCase().indexOf('opera') > -1) {
		window.parent.document.getElementById("toolbarframe").style.display="none";
	}
}

function showtoolbar() {
	document.getElementById("toolbarframe").style.display = "block";
}

//树形菜单
function treeView() {
	var list = document.getElementsByTagName('div');
	for ( i=0; i<list.length; i++ ) {
		list[i].getElementsByTagName('h5')[0].onclick = function() {
			if (this.parentNode.getElementsByTagName('ul')[0].style.display == '') {
				this.parentNode.getElementsByTagName('ul')[0].style.display = 'none';
			} else {
				this.parentNode.getElementsByTagName('ul')[0].style.display = '';
			}
		}
	}	
	var linkitem = document.getElementsByTagName('a');	
	for ( j=0; j<linkitem.length; j++ ) {
		//alert(linkitem[j]);
		linkitem[j].onclick = function() {
			for ( k=0; k<linkitem.length; k++ ) {
				linkitem[k].parentNode.className = '';
			}
			this.parentNode.className = 'selected';
			this.blur();
		}
	}
}

//切换频道
function channelNav(Obj, channel) {
	var channelTabs = document.getElementById('topMenus').getElementsByTagName('LI');
	for (i=0; i<channelTabs.length; i++) {
		channelTabs[i].className = '';
	}
	Obj.parentNode.className = 'actived';
	Obj.blur();	
	var sideDoc = window.parent.leftframe.document;
	var sideChannels = sideDoc.getElementsByTagName('div')
	for (i=0; i<sideChannels.length; i++) {
		sideChannels[i].style.display = '';
	}	
	var sideChannelLinks = sideDoc.getElementsByTagName('a')
	for (i=0; i<sideChannelLinks.length; i++) {
		sideChannelLinks[i].className = '';
	}
	var targetChannels = channel.split(',');
	for (i=0; i<targetChannels.length; i++) {
		var theLI = sideDoc.getElementById(targetChannels[0]).getElementsByTagName('a')[0];
		theLI.parentNode.className = 'selected';
		sideDoc.getElementById(targetChannels[i]).style.display = "block";
	}
}

//侧栏开关
function sideSwitch() {
	var mainFrame = window.parent.document.getElementById('mainframeset');
	var switcher = document.getElementById('sideswitch');
	if (mainFrame.cols == '0,*') {
		mainFrame.cols = '172,*';
		switcher.innerHTML = '隐藏左栏';
		switcher.className = 'opened';
	} else {
		mainFrame.cols = '0,*';
		switcher.innerHTML = '显示左栏';
		switcher.className = 'closed';
	}
}
